<?php

namespace app\admin\controller\ucenter;
use app\admin\controller\Base;
use think\facade\Request;
use think\facade\View;

class UserLevel extends Base
{
    protected $model;
    public function initialize()
    {
        parent::initialize();
        $this->model = new \app\admin\model\ucenter\UserLevel;
        $this->redict = url('index');
    }
    public function index(){
        if (Request::isPost()) {
            $keys = $this->request->post('keys', '', 'trim');
            $option = [];
            $list = $this->model->loadList($option);
            if ($list['result'] == 'success'){
                $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['list'], 'count' => $list['page']['total']];
            }else{
                $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => [], 'count' => 0];
            }
            return $result;
        }
        return view();
    }

    public function add(){
        if (Request::isPost()) {
            return parent::create();
        }
        return parent::add();
    }
    public function edit(){
        if (Request::isPost()) {
            return parent::modify();
        }
        return parent::read('add');


    }
}